/*****************************************************\
* Copyright (c) 2020 The game2d Authors. All rights reserved.
  Use of this source code is governed by a BSD-style license that can be
  found in the LICENSE file.

* Author:         dzlua - https://gitee.com/dzlua/game2d.git
* Email:          505544956@qq.com
* FileName:       utils/base.hpp
* Create Time:    2020/03/21 11:38:52
* Description:    /
\****************************************************/
#ifndef __GAME2D_UTILS_UTILS__HPP__
#define __GAME2D_UTILS_UTILS__HPP__

#include <SDL.h>

namespace g2d {
  
struct TextureData;
namespace ctrl {
  enum class HorAlign : Uint8;
  enum class VerAlign : Uint8;
  struct Inset;
}

struct Size {
  float w,h;
  Size() : w(0.f), h(0.f) {}
  Size(float _w, float _h) : w(_w), h(_h) {}
};

struct Sizei {
  int w,h;
  Sizei() : w(0), h(0) {}
  Sizei(int _w, int _h) : w(_w), h(_h) {}
};

namespace utils {
  Uint8 parse_hex(const char c, Uint8 def = 0);
  bool parse_bool(const char *value, bool def = false);
  int parse_int(const char *value, int def = 0);
  Uint32 parse_uint32(const char *value, Uint32 def = 0);
  float parse_float(const char *value, float def = 0.f);
  SDL_FPoint parse_pos(const char *value, float def = 0.f);
  Sizei parse_sizei(const char *value, int def = 0);
  Size parse_size(const char *value, float def = 0.f);
  SDL_Color parse_color(const char *value, Uint8 def = 0);
  g2d::TextureData parse_image(const char *value);
  g2d::ctrl::HorAlign parse_halign(const char *value);
  g2d::ctrl::VerAlign parse_valign(const char *value);
  g2d::ctrl::Inset parse_inset(const char *value, float def = 0.f);
} // end namespace utils
} // end namespace g2d

#endif // __GAME2D_UTILS_UTILS__HPP__